import java.io.File;
import java.util.List;

import datastore.ParticipantDatastore;
import datastore.User;

public class FileGraderRunner {
   public static void main(String[] args) {
      final ParticipantDatastore datastore = null;
      FileSystemListener fileListener = new FileSystemListener("C:\\Users\\jjnguy\\Desktop\\FileGraderFiles", 1000);
      fileListener.addChangeListener(new FileSystemListener.ChangeListener() {
         @Override
         public void fileSystemChanged(List<File> changedFiles) {
            for (File changed : changedFiles) {
               String[] path = changed.getAbsolutePath().split(File.separator);
               String userName = path[path.length-2];
               String problemName = path[path.length-1];
               User u = datastore.getParticipant(userName);
               u.putSubmission(problemName, changed);
            }
         }
      });
      Thread t = new Thread(fileListener);
      t.start();
   }
}
